<template>
  <div class="city">
    <city-header/>
    <city-list :hotCities="hotCities" :cities="cities"/>
    <city-alphabet :cities="cities"/>
  </div>
</template>

<script>
import CityHeader from '@/components/CityHeader'
import CityList from '@/components/CityList'
import CityAlphabet from '@/components/CityAlphabet'
import axios from 'axios'
export default {
  name: 'City',
  components: {
    CityHeader,
    CityList,
    CityAlphabet
  },
  data () {
    return {
      hotCities: [],
      cities: {}
    }
  },
  methods: {
    getCityInfo () {
      axios.get('./api/city.json')
        .then(this.getCityInfoSucc)
    },
    getCityInfoSucc (res) {
      res = res.data
      if (res.ret) {
        const data = res.data
        this.hotCities = data.hotCities
        this.cities = data.cities
      }
    }
  },
  mounted () {
    this.getCityInfo()
  }
}
</script>

<style lang="stylus" scoped>
  .city
    background #f5f5f5
</style>
